package com.hy.aicodegeneration.ai.guardrail.service.impl;

import com.hy.aicodegeneration.ai.guardrail.service.PromptSafetyEventService;
import com.hy.aicodegeneration.ai.guardrail.mapper.PromptSafetyEventMapper;
import com.hy.aicodegeneration.model.entity.PromptSafetyEvent;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 提示词安全事件记录服务实现
 *
 */
@Service
@Slf4j
public class PromptSafetyEventServiceImpl extends ServiceImpl<PromptSafetyEventMapper, PromptSafetyEvent> implements PromptSafetyEventService {

    @Override
    public boolean recordSafetyEvent(PromptSafetyEvent event) {
        try {
            return this.save(event);
        } catch (Exception e) {
            log.error("记录安全事件失败: {}", e.getMessage(), e);
            // 记录失败不应影响主流程
            return false;
        }
    }
}